package indi.xliuovo.coursedesign.musicplayer;

import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class AboutActivity extends AppCompatActivity implements View.OnClickListener {

    private String tip = "正在努力开发，敬请期待...";

    private TextView toCheckDialog, toCheckProtocol, toCheckPolicy, toCheckCertificates;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);

        initViews();

        // 实现顶部返回按钮
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setHomeButtonEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                this.finish(); // back button
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    // 初始化控件
    void initViews() {
        toCheckDialog = (TextView) findViewById(R.id.checkDialog);
        toCheckDialog.setOnClickListener(this);
        toCheckProtocol = (TextView) findViewById(R.id.protocol);
        toCheckProtocol.setOnClickListener(this);
        toCheckPolicy = (TextView) findViewById(R.id.policy);
        toCheckPolicy.setOnClickListener(this);
        toCheckCertificates = (TextView) findViewById(R.id.certificates);
        toCheckCertificates.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Toast.makeText(getApplicationContext(), tip, Toast.LENGTH_SHORT).show();
    }
}